package cn.sfrog.system.service.impl;

import cn.sfrog.common.utils.DateUtils;
import cn.sfrog.system.domain.SysCity;
import cn.sfrog.system.domain.vo.app.AppCityLetterListVO;
import cn.sfrog.system.mapper.SysCityMapper;
import cn.sfrog.system.service.ISysCityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 城市Service业务层处理
 */
@Service
public class SysCityServiceImpl extends ServiceImpl<SysCityMapper, SysCity> implements ISysCityService {
    @Autowired
    private SysCityMapper sysCityMapper;

    /**
     * 查询城市
     *
     * @param id 城市主键
     * @return 城市
     */
    @Override
    public SysCity selectSysCityById(Long id)
    {
        return sysCityMapper.selectSysCityById(id);
    }

    /**
     * 查询城市列表
     *
     * @param sysCity 城市
     * @return 城市
     */
    @Override
    public List<SysCity> selectSysCityList(SysCity sysCity)
    {
        return sysCityMapper.selectSysCityList(sysCity);
    }

    /**
     * 新增城市
     *
     * @param sysCity 城市
     * @return 结果
     */
    @Override
    public int insertSysCity(SysCity sysCity)
    {
        sysCity.setCreateTime(DateUtils.getNowDate());
        return sysCityMapper.insertSysCity(sysCity);
    }

    /**
     * 修改城市
     *
     * @param sysCity 城市
     * @return 结果
     */
    @Override
    public int updateSysCity(SysCity sysCity)
    {
        sysCity.setUpdateTime(DateUtils.getNowDate());
        return sysCityMapper.updateSysCity(sysCity);
    }

    /**
     * 批量删除城市
     *
     * @param ids 需要删除的城市主键
     * @return 结果
     */
    @Override
    public int deleteSysCityByIds(Long[] ids)
    {
        return sysCityMapper.deleteSysCityByIds(ids);
    }

    /**
     * 删除城市信息
     *
     * @param id 城市主键
     * @return 结果
     */
    @Override
    public int deleteSysCityById(Long id)
    {
        return sysCityMapper.deleteSysCityById(id);
    }

    @Override
    public String selectCodeByName(String name) {
        return sysCityMapper.selectCodeByName(name);
    }

    @Override
    public List<SysCity> selectSysCityByParent(Long parentId) {
        return sysCityMapper.selectSysCityByParent(parentId);
    }

    @Override
    public SysCity getCityByName(String name) {
        return sysCityMapper.getCityByName(name);
    }

    @Override
    public List<AppCityLetterListVO> groupByCityLetter(String keywords) {
        return sysCityMapper.groupByCityLetter(keywords);
    }

}
